package 常用api;

public class Join {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    //循环三次每次休眠一秒钟并且打印
                    for (int i = 0; i < 3; i++) {
                        System.out.println("t run" + i);
                        Thread.sleep(1000);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();
        //t线程加入到当前线程，表示当前线程等待t线程执行完之后再执行后后边的。
        t.join();
        System.out.println("main run");
    }
}
